; .686P
; .model flat, c
;  MessageBoxA proto stdcall,:dword,:dword,:dword,:dword
;  ExitProcess proto stdcall :dword
;  scanf       proto c :vararg
;  printf      proto c :vararg
;  includelib  user32.lib						;;MessageBoxA()
;  includelib  kernel32.lib					;;ExitProcess()
;  includelib  libcmt.lib						;;_mainCRTStartup => main
;  includelib  legacy_stdio_definitions.lib	;;printf

;  .data 
;  SAMID db "000001" 	    ;每组数据的流水号
;  SDA dd  256809       ;状态信息a
;  SDB dd  -1023        ;状态信息b
;  SDC dd   1265        ;状态信息c
;  SF   dd   ?          ;处理结果f
;  ANS dd ?
;  LOWF dd 3 dup(?)
;  MIDF dd 3 dup(?)
;  HIGHF dd 3 dup(?)

;  .stack 200

;  .code
;  main	proc
;  start:
;  mov eax, SDA
;  lea eax, [eax+eax*4]
;  add eax, SDB
;  sub eax, SDC
;  add eax, 100
;  sar eax, 7
;  cmp eax, 100
;  jl L1
;  jg L2
;  je L3
;  L1:
;  	mov ebx, offset LOWF
; 	jmp L4
;  L2:
;  	mov ebx, offset HIGHF
; 	jmp L4
;  L3:
;  	mov ebx, offset MIDF
; 	jmp L4
;  L4:
; 	mov eax, dword ptr SAMID
; 	mov [ebx], eax
; 	mov ax, word ptr SAMID + 4
; 	mov 4[ebx], ax
; 	mov eax, SDA
; 	mov 6[ebx], eax
; 	mov eax, SDB
; 	mov 10[ebx], eax
; 	mov eax, SDC
; 	mov 14[ebx], eax

;  invoke ExitProcess, 0
; main	endp
; 		end	
 


 .686P
.model flat, c
 MessageBoxA proto stdcall,:dword,:dword,:dword,:dword
 ExitProcess proto stdcall :dword
 scanf       proto c :vararg
 printf      proto c :vararg
 includelib  user32.lib						;;MessageBoxA()
 includelib  kernel32.lib					;;ExitProcess()
 includelib  libcmt.lib						;;_mainCRTStartup => main
 includelib  legacy_stdio_definitions.lib	;;printf

 .data 
 SAMID db "000001" 	  ;每组数据的流水号
 SDA dd  256809       ;状态信息a
 SDB dd  -1023        ;状态信息b
 SDC dd  1265         ;状态信息c
 SF   dd   ?          ;处理结果f
 LOWF dd 3 dup(?)
 MIDF dd 3 dup(?)
 HIGHF dd 3 dup(?)

 .stack 200

 .code
 main	proc
 start:
 mov eax, 5
 imul SDA ; edx,eax = a * 5
 add eax, SDB ; eax = eax + b
 cmp SDB, 0 ; 加负数则不执行高位加法
 jl L1
 adc edx, 0
 L1:
	sub eax, SDC ; eax = eax - c
	cmp SDC, 0 ; 减负数则不执行高位减法
	jl L2
	sbb edx, 0
 L2:
	add eax, 100 ; eax = eax + 100
	adc eax, 0
	mov ebx, 128
	idiv ebx ; eax = eax / 128
	mov SF, eax
	cmp eax, 100 ; if (eax < 100)
	jl L3
	jg L4
	je L5
 L3:
 	mov ebx, offset LOWF
	jmp L6
 L4:
 	mov ebx, offset HIGHF
	jmp L6
 L5:
 	mov ebx, offset MIDF
	jmp L6
 L6:
	mov eax, dword ptr SAMID
	mov [ebx], eax
	mov ax, word ptr SAMID + 4
	mov 4[ebx], ax
	mov eax, SDA
	mov 6[ebx], eax
	mov eax, SDB
	mov 10[ebx], eax
	mov eax, SDC
	mov 14[ebx], eax
 invoke ExitProcess, 0
main	endp
		end	


